import random


def sparseObstacle(obstacleNum, length, width, startPoint, endPoint, mostR, minR):
    obstacle = []
    for i in range(obstacleNum):
        x = 0
        y = 0  # 二维坐标，作为障碍物的圆心
        r = 0  # 障碍物半径
        while pow(startPoint[0] - x, 2) + pow(startPoint[1] - y, 2) <= pow(r, 2) or pow(endPoint[0] - x, 2) + pow(
                endPoint[1] - y, 2) <= pow(r, 2):
            # 限制起点与终点不能被障碍物覆盖
            x = random.uniform(0, length - 1)
            y = random.uniform(0, width - 1)
            r = random.uniform(minR, mostR) # 随机坐标与半径大小
        location = (x, y, r)
        obstacle.append(location)
    return obstacle
